﻿Imports System.Data
Imports VSModel
Imports Cls_Common
Imports SecurityService

Partial Class Control_MSDS_Section15View
    Inherits System.Web.UI.UserControl
	Private Shared ReadOnly log As log4net.ILog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)
#Region "Sub and Function "
	Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
		If Not IsPostBack Then
			Dim script As ScriptManager = ScriptManager.GetCurrent(Me.Page)
			If Not script Is Nothing AndAlso script.IsInAsyncPostBack Then
				ScriptManager.RegisterStartupScript(Me.Page, Me.Page.GetType, "duyjs", "ajaxJquery()", True)
			Else
				Me.Page.ClientScript.RegisterStartupScript(Me.Page.GetType(), "duyjs", String.Concat("Sys.Application.add_load(function(){", "ajaxJquery()", "});"), True)
			End If
			Translate()
			hidMSDSId.Value = IIf(IsNothing(Request.QueryString("Id")), 0, CInt(Request.QueryString("Id")))
			ShowData()
		End If
	End Sub
	Protected Sub Translate()
		lblSection15Header.Text = getTranslate("lblSection15Header", Session("LanguageId"), lblSection15Header.Text)
		lblS1511.Text = getTranslate("lblS1511", Session("LanguageId"), lblS1511.Text)
		lblS1521.Text = getTranslate("lblS1521", Session("LanguageId"), lblS1521.Text)
	End Sub
	Protected Sub ShowData()
		Using data As New VSEntities
			'Tiêu đề doanh nghiệp
			Dim lang = CInt(Session("LanguageId"))
			Dim Id As Integer = hidMSDSID.Value
			Dim p As MSDSSection15 = (From a In data.MSDSSection15 Where a.MSDSId = Id And a.LanguageId = lang).SingleOrDefault
			If Not IsNothing(p) Then
				'Content
				txtS1511.Text = IIf(IsNothing(p.S1511) = True, "", p.S1511)
				txtS1521.Text = IIf(IsNothing(p.S1521) = True, "", p.S1521)
			End If
			'Label
			Translate()
		End Using
	End Sub
#End Region
End Class
